
 /*********************************************************
 *
 *  Project:      HZFlashCards
 *
 *  Class:        FileChooserAccessoryPanel
 *
 *  File name:    FileChooserAccessoryPanel.java
 *
 *
 *    SVN:
 *
 *    $Rev$:
 *    $Date$:
 *    $LastChangedBy$:
 *
 *    $HeadURL$:
 *
 **********************************************************/

package com.eastmountain.chinese.gui.controllers;

import java.awt.Color;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.Border;

import com.eastmountain.chinese.gui.FileChooser;


/*********************************************************
 *
 *  Class:        FileChooserAccessoryPanel
 *
 **********************************************************/

@SuppressWarnings("serial")
public class FileChooserAccessoryPanel extends JPanel implements ActionListener {

        private JRadioButton flashCardList;
        private JRadioButton reviewList;
        private JRadioButton characterWordXRF;

        private Border emptyBorder = BorderFactory.createEmptyBorder( 4, 4, 4, 4 );
        private Border lineBorder = BorderFactory.createLineBorder( Color.BLACK, 2 );
        private Border compoundBorder = BorderFactory.createCompoundBorder( emptyBorder, lineBorder );

        public FileChooserAccessoryPanel( FileChooser fileChooser ) {

            setLayout( new BoxLayout( this, BoxLayout.Y_AXIS) );

            setBorder( compoundBorder );

            add( Box.createVerticalGlue() );

            flashCardList = new JRadioButton( FileChooser.FLASHCARD_LIST );
            flashCardList.setMnemonic( KeyEvent.VK_P );
            flashCardList.addActionListener( this );

            add( flashCardList );

            reviewList = new JRadioButton( FileChooser.REVIEW_LIST );
            reviewList.setMnemonic( KeyEvent.VK_P );
            reviewList.addActionListener( this );
            reviewList.setSelected(true);

            add( reviewList );

            characterWordXRF = new JRadioButton( FileChooser.CHARACTER_WORD_XRF );
            characterWordXRF.setMnemonic( KeyEvent.VK_P );
            characterWordXRF.addActionListener( this );

            add( characterWordXRF );

            add( Box.createVerticalGlue() );

          //Group the radio buttons.

            ButtonGroup group = new ButtonGroup();
            group.add( flashCardList );
            group.add( reviewList );
            group.add( characterWordXRF );

        }

        public void actionPerformed( ActionEvent event ) {

            //Handle open button action.

            String command = event.getActionCommand();

            if ( FileChooser.FLASHCARD_LIST.equals( command ) ) {

            } else if ( FileChooser.REVIEW_LIST.equals( command ) ) {

            }  else if ( FileChooser.CHARACTER_WORD_XRF.equals( command ) ) {

            }

        }

        protected static ImageIcon createImageIcon(String path) {
            java.net.URL imgURL = FileChooser.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
            }
        }

        @Override
        public Insets getInsets() {

            return new Insets( 10, 10, 10, 10);
        }

    }


